home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 8 / QRZ Ham Radio Callsign Database - Volume 8.iso / pc / files / t_unix / j109lxa4.tar / netrom.h < prev    next >
C/C++ Source or Header  |  1994-06-04  |  7KB  |  208 lines

  1. #ifndef    _NETROM_H
  2. #define    _NETROM_H
  3.  
  4. #ifndef    _MBUF_H
  5. #include "mbuf.h"
  6. #endif
  7.  
  8. #ifndef    _IFACE_H
  9. #include "iface.h"
  10. #endif
  11.  
  12. #ifndef    _AX25_H
  13. #include "ax25.h"
  14. #endif
  15.  
  16. #ifndef _NR4_H
  17. #include "nr4.h"
  18. #endif
  19.  
  20. /* net/rom support definitions
  21.  * Copyright 1989 by Daniel M. Frank, W9NK.  Permission granted for
  22.  * non-commercial distribution only.
  23.  */
  24.  
  25. #define NR3HLEN        15    /* length of a net/rom level 3 hdr, */
  26. #define NR3DLEN        241    /* max data size in net/rom l3 packet */
  27. #define NR3NODESIG    0xff    /* signature for nodes broadcast */
  28. #define NR3POLLSIG  0xfe    /* signature for route poll - WG7J */
  29. #define NR3NODEHL   7   /* nodes bc header length */
  30.  
  31. #define NRNUMCHAINS    17    /* number of chains in the */
  32.                 /* neighbor and route hash tables */
  33. #define NRRTDESTLEN    21    /* length of destination entry in */
  34.                 /* nodes broadcast */
  35. #define NRDESTPERPACK    11    /* maximum number of destinations per */
  36.                 /* nodes packet */
  37.  
  38. /* NET/ROM protocol numbers */
  39. #define NRPROTO_IP    0x0c
  40.  
  41. /* Internal representation of net/rom network layer header */
  42. struct nr3hdr {
  43.     char source[AXALEN] ;    /* callsign of origin node */
  44.     char dest[AXALEN] ;        /* callsign of destination node */
  45.     unsigned ttl ;                /* time-to-live */
  46. } ;
  47.  
  48. /* Internal representation of net/rom routing broadcast destination */
  49. /* entry */
  50. struct nr3dest {
  51.     char dest[AXALEN] ;        /* destination callsign */
  52.     char alias[AXALEN] ;            /* ident, upper case ASCII, blank-filled */
  53.     char neighbor[AXALEN] ;    /* best-quality neighbor */
  54.     unsigned quality ;        /* quality of route for this neighbor */
  55. } ;
  56.  
  57. /* net/rom neighbor table structure */
  58. struct nrnbr_tab {
  59.     struct nrnbr_tab *next ;    /* doubly linked list pointers */
  60.     struct nrnbr_tab *prev ;
  61.     char call[AXALEN] ;         /* call of neighbor + 2 digis max */
  62.     struct iface *iface ;
  63.     unsigned refcnt ;           /* how many routes for this neighbor? */
  64.     int32 lastsent;             /* time when last sent via this neigbour */
  65. } ;
  66.  
  67. #define    NULLNTAB    (struct nrnbr_tab *)0
  68.  
  69.  
  70. /* A list of these structures is provided for each route table */
  71. /* entry.  They bind a destination to a neighbor node.  If the */
  72. /* list of bindings becomes empty, the route table entry is    */
  73. /* automatically deleted.                                       */
  74.  
  75. struct nr_bind {
  76.     struct nr_bind *next ;        /* doubly linked list */
  77.     struct nr_bind *prev ;
  78.     unsigned quality ;        /* quality estimate */
  79.     unsigned obsocnt ;        /* obsolescence count */
  80.     unsigned flags ;
  81. #define    NRB_PERMANENT    0x01        /* entry never times out */
  82. #define NRB_RECORDED    0x02        /* a "record route" entry */
  83.     struct nrnbr_tab *via ;        /* route goes via this neighbor */
  84. } ;
  85.  
  86. #define    NULLNRBIND    (struct nr_bind *)0
  87.  
  88.  
  89. /* net/rom routing table entry */
  90.  
  91. struct nrroute_tab {
  92.     struct nrroute_tab *next ;    /* doubly linked list pointers */
  93.     struct nrroute_tab *prev ;
  94.     char alias[AXALEN] ;            /* alias of node */
  95.     char call[AXALEN] ;        /* callsign of node */
  96.     unsigned num_routes ;        /* how many routes in bindings list? */
  97.     struct nr_bind *routes ;    /* list of neighbors */
  98.  
  99. } ;
  100.  
  101. #define    NULLNRRTAB    (struct nrroute_tab *)0
  102.  
  103.  
  104. /* The net/rom nodes broadcast filter structure */
  105. struct nrnf_tab {
  106.     struct nrnf_tab *next ;        /* doubly linked list */
  107.     struct nrnf_tab *prev ;
  108.     char neighbor[AXALEN] ;     /* call of neighbor to filter */
  109.     struct iface *iface ;       /* filter on this interface */
  110.     unsigned quality;           /* explicit quality of this node */
  111. } ;
  112.  
  113. #define    NULLNRNFTAB    (struct nrnf_tab *)0
  114.  
  115. /* Structure for handling raw NET/ROM user sockets */
  116. struct raw_nr {
  117.     struct raw_nr *prev;
  118.     struct raw_nr *next;
  119.  
  120.     struct mbuf *rcvq;    /* receive queue */
  121.     char protocol;        /* Protocol */
  122. };
  123. #define    NULLRNR    ((struct raw_nr *)0)
  124.  
  125. /* The neighbor hash table (hashed on neighbor callsign) */
  126. extern struct nrnbr_tab *Nrnbr_tab[NRNUMCHAINS] ;
  127.  
  128. /* The routes hash table (hashed on destination callsign) */
  129. extern struct nrroute_tab *Nrroute_tab[NRNUMCHAINS] ;
  130.  
  131. /* The nodes broadcast filter table */
  132. extern struct nrnf_tab *Nrnf_tab[NRNUMCHAINS] ;
  133.  
  134. extern char Nr_nodebc[AXALEN];
  135.  
  136. /* filter modes: */
  137. #define    NRNF_NOFILTER    0    /* don't filter */
  138. #define    NRNF_ACCEPT    1    /* accept broadcasts from stations in list */
  139. #define    NRNF_REJECT    2    /* reject broadcasts from stations in list */
  140.  
  141. /* The filter mode */
  142. extern unsigned Nr_nfmode ;
  143.  
  144. /* The time-to-live for net/rom network layer packets */
  145. extern unsigned short Nr_ttl ;
  146.  
  147. /* The obsolescence count initializer */
  148. extern unsigned Obso_init ;
  149.  
  150. /* The threshhold at which routes becoming obsolete are not broadcast */
  151. extern unsigned Obso_minbc ;
  152.  
  153. /* The quality threshhold below which routes in a broadcast will */
  154. /* be ignored */
  155. extern unsigned Nr_autofloor ;
  156.  
  157. /* Whether we want to broadcast the contents of our routing
  158.  * table, or just our own callsign and alias:
  159.  */
  160. extern int Nr_verbose ;
  161.  
  162. /* The maximum number of routes maintained for a destination. */
  163. /* If the list fills up, only the highest quality routes are  */
  164. /* kept.  This limiting is done to avoid possible over-use of */
  165. /* memory for routing tables in closely spaced net/rom networks. */
  166. extern unsigned Nr_maxroutes ;
  167.  
  168. /* The netrom pseudo-interface */
  169. extern struct iface *Nr_iface ;
  170.  
  171. /* Functions */
  172.  
  173. /* In nr3.c: */
  174. void del_rnr __ARGS((struct raw_nr *rpp));
  175. char *find_nralias __ARGS((char *));
  176. struct nrroute_tab *find_nrroute __ARGS((char *));
  177. void nr_bcnodes __ARGS((struct iface *ifp));
  178. void nr_bcpoll __ARGS((struct iface *ifp));
  179. void nr_nodercv __ARGS((struct iface *iface,char *source,struct mbuf *bp));
  180. int nr_nfadd __ARGS((char *, struct iface *, unsigned));
  181. int nr_nfdrop __ARGS((char *, struct iface *));
  182. void nr_route __ARGS((struct mbuf *bp,struct ax25_cb *iaxp));
  183. int nr_routeadd __ARGS((char *, char *, struct iface *,
  184.     unsigned, char *, unsigned, unsigned));
  185. int nr_routedrop __ARGS((char *, char *, struct iface *));
  186. int nr_send __ARGS((struct mbuf *bp,struct iface *iface,int32 gateway,int prec,
  187.     int del,int tput,int rel));
  188. void nr_sendraw __ARGS((char *dest,unsigned family,unsigned proto,
  189.     struct mbuf *data));
  190. void nr3output __ARGS((char *dest,struct mbuf *data));
  191. int16 nrhash __ARGS((char *s));
  192. struct raw_nr *raw_nr __ARGS((char));
  193. struct nrroute_tab *find_nrboth __ARGS((char *alias,char *call));
  194.  
  195. /* In nrcmd.c: */
  196. void donrdump __ARGS((struct nr4cb *cb));
  197. int doroutedump __ARGS((void));
  198. int dorouteinfo __ARGS((int argc,char *argv[],void *p));
  199. int putalias __ARGS((char *to, char *from,int complain));
  200.  
  201. /* In nrhdr.c: */
  202. struct mbuf *htonnr3 __ARGS((struct nr3hdr *));
  203. struct mbuf *htonnrdest __ARGS((struct nr3dest *));
  204. int ntohnr3 __ARGS((struct nr3hdr *, struct mbuf **));
  205. int ntohnrdest __ARGS((struct nr3dest *ds,struct mbuf **bpp));
  206.  
  207. #endif    /* _NETROM_H */
  208.